home *** CD-ROM | disk | FTP | other *** search
- Path: news.oanet.com!usenet
- From: mape@freenet.edmonton.ab.ca
- Newsgroups: comp.lang.c++
- Subject: Help: student with passing by pointer to functions problem
- Date: Mon, 18 Mar 1996 00:27:45 GMT
- Organization: Central News Services
- Message-ID: <4ii6s7$s2a@hermes.oanet.com>
- NNTP-Posting-Host: dialin11.oanet.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- Hi All,
-
- I'm a student at NAIT.ab.ca, and am taking an introduction to Windows
- programming course. I really enjoy his C++ language, but our text
- book has absolutly nothing on functions and far * pointers.
- Unfortunatly I won't be seeing the teacher before my Lab is due, so I
- thought I'd throw it out as a general question to the helpful
- individuals of this group.
- I am a little unclear as to how pass elements of a stucture form a
- dialog box function that is already using a far * pointer, to another
- function (a generic sort function).
-
- Here is an example of what I'm trying to do:
-
- struct GAMEDATA
- {
- LOGFONT lfText;
- COLORREF cTwoColor;
- COLORREF cOneColor;
- char aszName[5][5];
- int iNumName;
- };
-
- Is passed into the following dialogbox function:
- //prototype
- LRESULT CALLBACK fnAddPlayerProc( HWND, UINT, WPARAM, LPARAM );
-
- and called from a menu item case, where the LPARAM is typecast to a
- struct far *:
- case IDM_PLAYERS_ADD:
- {
- FARPROC lpfnDlg;
- GAMEDATA far * ptrD;
- ptrD = & stGData;
- lpfnDlg = MakeProcInstance(( FARPROC ) fnAddPlayerProc,ghInst );
- DialogBoxParam( ghInst, "AddPlayer", hWnd,( DLGPROC ) lpfnDlg, (
- LPARAM ) ptrD );
- FreeProcInstance( lpfnDlg );
- break;
- }
-
- In the function, it is typecast to a pointer to the struct in
- WM_INITDIALOG:
- LRESULT CALLBACK fnAddPlayerProc( HWND hDlg, UINT iMessage,
- WPARAM wParam, LPARAM lParam)
- {
- static GAMEDATA far * localPtr;switch( iMessage )
- switch( iMessage)
- case WM_INITDIALOG:
- {
- localPtr = (GAMEDATA far * )lParam;
- break;
- }
- case WM_COMMAND:
- {
-
- Here, I would like to call a generic function to do a bubble sort
- using localPtr->aszName and localPtr->iNumName
- //prototype
- void fnSort( HWND, aszNAM[][5], iNumN );
- //call
- fnSort(hDlg, localPtr->aszNames, localPtr->iNumName );
- //header
- void fnSort( HWND hDlg, char aszNAM[][5], int iNumN );
-
- This dosen't work.
- Do I have to typecast the pointer in the function?
- Do I have to pass it the HWND?
-
- Sincerely.
- Martin martp@oanet.com
- mape@freenet.edmonton.ab.ca
-
-